package LogisticsSystem.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import LogisticsSystem.mapper.DispatchMapper;
import LogisticsSystem.mapper.ext.DispatchExtendMapper;
import LogisticsSystem.po.Dispatch;
import LogisticsSystem.po.DispatchExample;
import LogisticsSystem.po.DispatchExample.Criteria;
import LogisticsSystem.po.ext.DispatchExtend;
import LogisticsSystem.service.DispatcherService;

/**
 * @author 作者 slim
 * @version 创建时间：2017年11月18日 上午11:06:01 类说明
 */
@Service
public class DispatchServiceImpl implements DispatcherService {

	@Autowired
	DispatchMapper dispatchMapper;

	@Autowired
	DispatchExtendMapper dispatchExtendMapper;

	@Override
	public List<DispatchExtend> getAllDispatchs() {
		List<DispatchExtend> list = dispatchExtendMapper.selectDispatchExtendList();
		System.out.println(list.size());
		return list;
	}

	@Override
	public int insertDispatchs(Dispatch dispatch) {
		return dispatchMapper.insert(dispatch);
	}

	@Override
	public int updateDispatchs(Dispatch dispatch) {
		return dispatchMapper.updateByPrimaryKeySelective(dispatch);
	}

	@Override
	public int deleteDispatchsById(int dId) {
		return dispatchMapper.deleteByPrimaryKey(dId);
	}

	@Override
	public List<DispatchExtend> getDispatchsBySId(Integer s_id) {
		return dispatchExtendMapper.selectDispatchExtendByStaffId(s_id);
	}

	@Override
	public DispatchExtend getDispatchByDId(Integer d_id) {
		return dispatchExtendMapper.selectDispatchExtendByDId(d_id);
	}

	@Override
	public List<Dispatch> selectByExample() {
		return dispatchMapper.selectByExample(null);
	}

	@Override
	public List<DispatchExtend> selectDispatchExtendByCId(int c_id) {
		return dispatchExtendMapper.selectDispatchExtendByCId(c_id);
	}

	@Override
	public Dispatch getDispatchByOId(Integer o_id) {
		DispatchExample example = new DispatchExample();
		Criteria criteria = example.createCriteria();
		return dispatchMapper.selectByExample(example).get(0);
	}

}
